package tag35_28_08.map.aufgabe;

public class Auto implements Comparable<Auto> {
	
	protected int id;
	protected String modell;
	
	public Auto(int id, String modell) {
		this.id = id;
		this.modell = modell;
	}
	
	@Override
	public String toString() {
		return id +" "+ modell;
	}
	

	@Override
	public int hashCode() {
		return modell.hashCode() + id;
	}
	
	@Override
	public boolean equals(Object obj) {
		
		if( !(obj instanceof Auto) )
			return false;
		
		if( getClass() != obj.getClass() )
			return false;
		
		Auto a2 = (Auto) obj;
		
		return modell.equals(a2.modell) && id==a2.id;
	}
	
	@Override
	public int compareTo(Auto a2) {
		int erg = modell.compareTo(a2.modell);
		
		if(erg!=0)
			return erg;
		
		return id - a2.id;
	}
}
